package org.meow.interception;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * &#064;Date: 24/04/22-17:27
 * &#064;Description: 调试用，打印请求信息
 */
@Component
public class DebugReqItcpt implements HandlerInterceptor {
  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (handler instanceof HandlerMethod)
      System.out.printf("\n== [%s] %s\n", request.getMethod(), request.getServletPath());
    return true; /* 直接放行 */
  }
}
